package com.beep.erp.model.login;

import com.beep.erp.common.bean.LoginBean;
import com.beep.erp.http.HttpExceptionHandle;
import com.beep.erp.http.HttpResultSubscriber;

/**
 * Created by jolly on 2018/8/24.
 */

public class LoginPresenter extends LoginContract.Presenter {
    @Override
    public void onStart() {

    }

    @Override
    public void login(String username, String pwd) {
        mView.showLoading();
        mRxManage.add(mModel.login(username, pwd).subscribe(new HttpResultSubscriber<LoginBean>() {
            @Override
            public void onError(HttpExceptionHandle.ResponeThrowable e) {
                mView.hideLoading();
                mView.showMessage(e.ErrorInfo);
            }

            @Override
            public void onNext(LoginBean loginBean) {
                mView.hideLoading();
                mView.login(loginBean);
            }
        }));
    }
}
